<template>
  <div class="cplist">
    <div class="rmlist">
      <div class="remitem" v-for="(item, index) in menus" :key="index">
        <div class="cpleft">
          <img :src="item.dishesImage" />
        </div>
        <div class="cpright">
          <div class="cptitle">
            <span>{{ item.dishesName }}</span>
          </div>
          <div class="cpxq">
            <span>{{ item.dishesDesc }}</span>
          </div>
          <div class="cpyp">
            <span>月销{{ item.monthAmount }}</span>
            <span>好评率{{ item.praiseRate }}</span>
          </div>
          <div class="monsl">
            <div class="mon">
              <span>￥{{ item.presentPrice }}</span>
              <span
                style="text-decoration:line-through;color:#999;font-size:0.25rem"
                >￥{{ item.dishesPrice }}</span
              >
            </div>
            <div clss="sl" v-if="isShowCount">
              <yd-spinner
                :longpress="false"
                height="20px"
                width="0.7rem"
                button-style="circle"
                v-model="item.num"
                min="0"
                :val="item.dishesId"
                :callback="select_menu"
              ></yd-spinner>
            </div>
          </div>
          <div class="zk">
            <span>{{ item.discount }}折</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Menu',
  props: {
    menus: {
      type: Array,
      default: () => {
        return [];
      }
    },
    isShowCount: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {};
  },

  methods: {
    /*
     * 用户选择菜品
     * 作者：gzt
     * 时间：2019-11-24 12:55:37
     */

    select_menu(goods_id, val) {
      console.log(goods_id+"~~~~~~~~~~");
      // 查找当前商品的单价
      var price = this.menus.find(ent => ent.dishesId == goods_id).presentPrice;
      let menu_data = {
        id: goods_id,
        price: price,
        num: val
      };
      this.$store.commit('SELECT_MENU', menu_data);
    }
  }
};
</script>

<style lang="less">
/* 点菜列表样式 */
.cpleft img {
  height: 1.8rem;
  width: 1.8rem;
}

.cplist {
  margin: 0.3rem 0rem;
  background: #fff;
  margin-bottom: 1.5rem;
}

.rmlist {
  padding: 0.2rem;
}

.remitem {
  display: flex;
  padding-bottom: 0.4rem;
}

.cpright {
  padding-left: 0.3rem;
  text-align: left;
  flex: 1;
}

.cptitle {
  font-size: 0.3rem;
  font-weight: bold;
}

.cpyp {
  color: #999;
}

.cpyp span {
  padding-right: 0.3rem;
}

.monsl {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.monsl span {
  font-size: 0.33rem;
  color: red;
  padding-right: 0.15rem;
}

.zk {
  color: rgb(241, 162, 14);
  font-size: 0.3rem;
}

/* 点菜列表样式 */
</style>
